#include "./PlayerArray.h"

using namespace Core;

unsigned char PlayerArray::INVALID_ID = 255;

PlayerArray::PlayerArray() {
	for( int i = 0; i < MAX_PLAYERS; ++i )
		players_[ i ] = 0;
}

PlayerArray::~PlayerArray() {
	clear();
}

unsigned char PlayerArray::getUniquePlayerId() {
	for( int i = 0; i < MAX_PLAYERS; ++i )
		if( players_[ i ] == 0) return i;
	return INVALID_ID;
}

void PlayerArray::clear() {
	for( int i = 0; i < MAX_PLAYERS; ++i )
		if( players_[ i ]  != 0) {
			delete players_[ i ];
			players_[ i ] = 0;
		}
}
